package com.cskaoyan.dbutils;

import com.cskaoyan.connectionpool.dbcp.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.MapHandler;
import org.apache.commons.dbutils.handlers.MapListHandler;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * 创建日期: 2022/07/28 17:28
 *
 * @author ciggar
 *
 * BeanListHandler
 *
 */
public class QueryDemo5 {

    public static void main(String[] args) throws SQLException {

        // 创建一个QueryRunner
        QueryRunner queryRunner = new QueryRunner(DruidUtils.getDataSource());

        List<Map<String,Object>> mapList = queryRunner.query("select * from city", new MapListHandler());

        for (Map<String, Object> map : mapList) {
            System.out.println(map);
        }
    }
}
